package com.qfedu.service.impl;

import com.qfedu.mapper.PermissionMapper;
import com.qfedu.model.Permission;
import com.qfedu.service.IPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 概述:
 *
 * @Author: Tbh
 * @Date: 2022/7/2 15:09
 */

@Service
public class PermissionServiceImpl implements IPermissionService {

    @Autowired
    private PermissionMapper permissionMapper;

    @Override
    public List<Permission> findAll(int id) {

        List<Permission> list = permissionMapper.findAll(id);

        for (Permission permission : list) {
            List<Permission> children = new ArrayList<>();

//          permission.setChildren(findAll(permission.getId()));
            children = findAll(permission.getId());
            permission.setChildren(children);
        }
        
        return list;
    }
}
